package com.tcm.pay.sign;

import com.tcm.pay.domain.dto.AggregatePayDTO;
import com.tcm.pay.util.RSAutil;

public class Sign {

    /**
     * 商户私钥
     */
    public static final String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIRbaoI777zV7ifPtjidDaKVCaRA\n" +
            "A5Yl+lr2GWJ/9LZWuWf1WYqzluBmEIwhxRwMCrDlHJFt2AFRuSzQckpnQRyA+5ZpqYfW3TtmLSqD\n" +
            "qzS5DHi55LnpDvjnBlZQH9bahVOlRzUFOKEwPl9W0L9iEzZNJcuALvvWOydVBnEG56r7AgMBAAEC\n" +
            "gYALkO2CyfgOOWehZP5Yfij13y5DgzCNC26QSlc3i1T4JiX3lrInc8AoheLGTCEsbUT15l+TudSZ\n" +
            "cOnMp76FD/bZhZ4ttm1ansBLvxQTcquyUPwpuv8hzpwmnmNuRPE5DHMrnVD/tgyO6BYdomT0SMDC\n" +
            "lYJPFrxjlqZw7F4uNccE2QJBAL8rPlykRRoKEn/WHfL1RZHZZhSS7ANmZomCQ5MDD+aebt8aiz1s\n" +
            "sLMSnTr/yMz0k2K9Gji+X4gzrJmzLIt4ab0CQQCxPkrhv1jQoYUZqgjSXouTFc6D2FEmQK1uAhlt\n" +
            "WDqyc1cBxw7BwAGgCU59gV2szxlcLTbMLduwPCfdj61DGgcXAkBRpVBvFKGGq4KXIoWL/IEH94eH\n" +
            "hfBSy2tDk2T05rvlzQihNJ7/TupwsKSCTDgggNxpsUX/sh7u9tLimgmOT5EpAkBwmHL3gBgKyWEF\n" +
            "kbfy9C7UrHi51xSOKW5DQUAn73GyZYUzUuI0ASbHJMJhBmqc2h9xKCP0h3lVNpHYtWpLA2DXAkEA\n" +
            "r2wriFKkf3kalerOyhtkCzLRb3qtJnxWH6slSZrXQW4g+kdZWABoLDV5FitXzwO7nF4KD+Ypk/jW\n" +
            "dF6ZDiDhfQ==";

    /**
     * 验签数据添加
     * @param aggregatePayDTO
     * @return
     */
    public AggregatePayDTO createData(AggregatePayDTO aggregatePayDTO){

        //签名内容
        String signContent="AdviceUrl="+aggregatePayDTO.getAdviceUrl()+"&Amount="+aggregatePayDTO.getAmount()+"&MerchantNo="
        +aggregatePayDTO.getMerchantNo()+"&MerchantOrderNo="+aggregatePayDTO.getMerchantOrderNo()+"&PayType="+aggregatePayDTO.getPayType()
                +"&RandomStr="+aggregatePayDTO.getRandomStr();

        //签名
        String signInfo = null;
        try {
            signInfo = RSAutil.sign(signContent, RSAutil.getPrivateKey(privateKey));
        } catch (Exception e) {
            e.printStackTrace();
        }
        aggregatePayDTO.setSignInfo(signInfo);

        aggregatePayDTO.setOrderTime(aggregatePayDTO.getOrderTime());
        return  aggregatePayDTO;
    }

}
